package com.dqp.cslggroup.UI;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.dqp.cslggroup.R;
import com.dqp.cslggroup.bean.Consumer;

import java.util.List;

/**
 * @author 董琴平
 * @version 1.0
 * @date 2021/9/4 22:24
 */
public class ConsumeAdapter extends BaseAdapter {

    private List<Consumer> consumers;
    private LayoutInflater inflater;
    private ConsumeAdapter ConsumeAdapter;

    public ConsumeAdapter(List<Consumer> grades, Context context) {
        this.consumers = grades;
        this.inflater = LayoutInflater.from(context);
    }


    public int getCount() {
        return consumers == null ? 0 : consumers.size();
    }


    public Object getItem(int position) {
        return consumers.get(position);
    }


    public long getItemId(int position) {
        return position;
    }


    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint("ViewHolder") View view = inflater.inflate(R.layout.four_textview_item, null);
        Consumer consumer = (Consumer) getItem(position);
        TextView textview_1 = view.findViewById(R.id.textview_1);
        TextView textview_2 = view.findViewById(R.id.textview_2);
        TextView textview_3 = view.findViewById(R.id.textview_3);
        TextView textview_4 = view.findViewById(R.id.textview_4);
        textview_1.setText(consumer.getTjyf());
        textview_2.setText(consumer.getScgw() + "");
        textview_3.setText(consumer.getCyxf() + "");
        textview_4.setText(consumer.getQtxf() + "");
        return view;
    }
}
